package com.example.medicine.controller;


import com.example.medicine.Bean.zhengzhuang;
import com.example.medicine.Mapper.xyjbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/xyjb")
public class xyjbController {
    @Autowired
    private xyjbMapper xyjbMapper;
    /**
     * 接收zhengzhuangList请求，返回数据库的zhengzhuang表内西医的所有内容，格式为json
     * @return
     */
    @GetMapping("/")
    public List<zhengzhuang> getzyjbList(){
        return xyjbMapper.getAll();
    }
    /**
     * 接收insertzhengzhuang请求，向zhengzhuang中插入内容
     */
    @PostMapping("/")
    public void inserxyjb(@RequestBody zhengzhuang zhengzhuang){
        xyjbMapper.insert(zhengzhuang);
    }

    @PutMapping("/")
    public void updatexyjb(@RequestBody zhengzhuang zhengzhuang){
        xyjbMapper.update(zhengzhuang);
    }

    @DeleteMapping("/{id}")
    public void deletexyjb(@PathVariable int id){
        xyjbMapper.deleteById(id);
    }
}
